package org.pgis.gui;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Toolkit;

import javax.swing.JFrame;
import javax.swing.JPanel;

import org.pgis.core.AbstractScenePanel;
import org.pgis.core.SurfaceScene;
import org.pgis.entity.ConnectingLine;
import org.pgis.gui.tbl.ConnectingLineTable;

import java.awt.Color;
import java.util.Vector;

public class MainWindow extends javax.swing.JFrame {

	private static MainWindow instance;
	private static final long serialVersionUID = 1L;
	private Dimension fullScreen;
	private AbstractScenePanel scene;
	private ConnectingLineTable connectingLineTable;

	public static MainWindow getInstance() {
		if (instance == null) {
			instance = new MainWindow();
		}

		return instance;
	}
    private MainWindow() {

        fullScreen = Toolkit.getDefaultToolkit().getScreenSize();
        initComponents();
		this.setSize(fullScreen.width - 30, fullScreen.height - 20);

    }

    private void initComponents() {

    	connectingLineTable = new ConnectingLineTable();

        panelContent = new javax.swing.JPanel();
        splitHorizontal = new javax.swing.JSplitPane();
        panelImageContent = new javax.swing.JPanel();
        splitVertical = new javax.swing.JSplitPane();
        scrollTools = new javax.swing.JScrollPane();
        panelToolLoad = new javax.swing.JPanel();
        scrollImageObjects = new javax.swing.JScrollPane();
        panelImageObjects = new javax.swing.JPanel();
        panelLeftToolBar = new javax.swing.JPanel();
        toolImport = new javax.swing.JButton();
        toolAddFile = new javax.swing.JButton();
        toolAddFile.setEnabled(false);
        toolTransform = new javax.swing.JButton();
        toolView = new javax.swing.JButton();
        toolMeasure = new javax.swing.JButton();
        toolInOutView = new javax.swing.JButton();
        toolLight = new javax.swing.JButton();
        toolCliping = new javax.swing.JButton();
        toolScaling = new javax.swing.JButton();
        toolColor = new javax.swing.JButton();
        panelStatusBar = new javax.swing.JPanel();
        panelToolBar = new javax.swing.JPanel();
        toolLeftArrow = new javax.swing.JButton();
        toolLeftArrow.setEnabled(false);
        toolRightArrow = new javax.swing.JButton();
        toolRightArrow.setEnabled(false);
        toolUpArrow = new javax.swing.JButton();
        toolUpArrow.setEnabled(false);
        toolDownArrow = new javax.swing.JButton();
        toolDownArrow.setEnabled(false);
        buttonClose = new javax.swing.JButton();
        menuBar = new javax.swing.JMenuBar();
        menuItemFile = new javax.swing.JMenu();
        menuImportImage = new javax.swing.JMenuItem();
        menuSave = new javax.swing.JMenuItem();
        menuSaveAs = new javax.swing.JMenuItem();
        menuExit = new javax.swing.JMenuItem();
        menuItemEdit = new javax.swing.JMenu();
        menuObjectColor = new javax.swing.JMenuItem();
        menuBackColor = new javax.swing.JMenuItem();
        menuUndo = new javax.swing.JMenuItem();
        menuRedo = new javax.swing.JMenuItem();
        menuDelete = new javax.swing.JMenuItem();
        menuItemOption = new javax.swing.JMenu();
        menuLight = new javax.swing.JMenuItem();
        menuCamera = new javax.swing.JMenuItem();
        menuTransform = new javax.swing.JMenuItem();
        menuScale = new javax.swing.JMenuItem();
        menuItemImage = new javax.swing.JMenu();
        menuClip = new javax.swing.JMenuItem();
        menuQuality = new javax.swing.JMenuItem();
        menuOpacity = new javax.swing.JMenuItem();
        menuItemView = new javax.swing.JMenu();
        menuSolidView = new javax.swing.JMenuItem();
        menuWireframe = new javax.swing.JMenuItem();
        menuPoint = new javax.swing.JMenuItem();

        setIconImage(new javax.swing.ImageIcon((MainWindow.class.getResource("/org/pgis/image/icon.png"))).getImage());
        setTitle("SciMed");
        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setExtendedState(JFrame.MAXIMIZED_BOTH);

        panelContent.setBackground(new java.awt.Color(255, 255, 255));
        panelContent.setLayout(new java.awt.BorderLayout());

        panelImageContent.setBackground(new java.awt.Color(0, 0, 0));
        panelImageContent.setMinimumSize(new java.awt.Dimension(400, 10));

        splitHorizontal.setLeftComponent(panelImageContent);


        splitVertical.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
        splitVertical.setMinimumSize(new java.awt.Dimension(250, 53));
        splitVertical.setPreferredSize(new java.awt.Dimension(250, 11));

        panelToolLoad.setLayout(new BorderLayout());
        panelToolLoad.add(connectingLineTable);
        panelToolLoad.setBackground(new java.awt.Color(102, 102, 102));
        scrollTools.setViewportView(panelToolLoad);
        splitVertical.setLeftComponent(scrollTools);

        setDefaultSpliterLocations(fullScreen);

        panelImageObjects.setBackground(Color.GRAY);
        scrollImageObjects.setViewportView(panelImageObjects);
        scrollImageObjects.setMinimumSize(new Dimension(250, 250));
        splitVertical.setRightComponent(scrollImageObjects);

        ///panelContent.add(splitVertical, BorderLayout.EAST);
        splitHorizontal.setRightComponent(splitVertical);
        panelContent.add(splitHorizontal, BorderLayout.CENTER);

        getContentPane().add(panelContent, java.awt.BorderLayout.CENTER);

        panelLeftToolBar.setBackground(new java.awt.Color(102, 102, 102));
        panelLeftToolBar.setPreferredSize(new java.awt.Dimension(60, 10));
        panelLeftToolBar.setLayout(new javax.swing.BoxLayout(panelLeftToolBar, javax.swing.BoxLayout.Y_AXIS));

        toolImport.setIcon(new javax.swing.ImageIcon(MainWindow.class.getResource("/org/pgis/image/file-import-icon.png"))); // NOI18N
        toolImport.setFocusable(false);
        toolImport.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        toolImport.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        toolImport.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                toolImportActionPerformed(evt);
            }
        });
        panelLeftToolBar.add(toolImport);

        toolAddFile.setIcon(new javax.swing.ImageIcon(MainWindow.class.getResource("/org/pgis/image/add-file.png"))); // NOI18N
        toolAddFile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                toolAddFileActionPerformed(evt);
            }
        });
        panelLeftToolBar.add(toolAddFile);

        toolTransform.setIcon(new javax.swing.ImageIcon(MainWindow.class.getResource("/org/pgis/image/transform.png"))); // NOI18N
        toolTransform.setFocusable(false);
        toolTransform.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        toolTransform.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        toolTransform.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                toolTransformActionPerformed(evt);
            }
        });
        panelLeftToolBar.add(toolTransform);

        toolView.setIcon(new javax.swing.ImageIcon(MainWindow.class.getResource("/org/pgis/image/view.png"))); // NOI18N
        toolView.setFocusable(false);
        toolView.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        toolView.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        toolView.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                toolViewActionPerformed(evt);
            }
        });
        panelLeftToolBar.add(toolView);

        toolMeasure.setIcon(new javax.swing.ImageIcon(MainWindow.class.getResource("/org/pgis/image/measure.png"))); // NOI18N
        toolMeasure.setFocusable(false);
        toolMeasure.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        toolMeasure.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        toolMeasure.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                toolMeasureActionPerformed(evt);
            }
        });
        panelLeftToolBar.add(toolMeasure);

        toolInOutView.setIcon(new javax.swing.ImageIcon(MainWindow.class.getResource("/org/pgis/image/inner.png"))); // NOI18N
        toolInOutView.setFocusable(false);
        toolInOutView.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        toolInOutView.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        toolInOutView.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                toolInOutViewActionPerformed(evt);
            }
        });
        panelLeftToolBar.add(toolInOutView);

        toolLight.setIcon(new javax.swing.ImageIcon(MainWindow.class.getResource("/org/pgis/image/bulb.png"))); // NOI18N
        toolLight.setFocusable(false);
        toolLight.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        toolLight.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        toolLight.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                toolLightActionPerformed(evt);
            }
        });
        panelLeftToolBar.add(toolLight);

        toolCliping.setIcon(new javax.swing.ImageIcon(MainWindow.class.getResource("/org/pgis/image/cut.png"))); // NOI18N
        toolCliping.setFocusable(false);
        toolCliping.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        toolCliping.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        toolCliping.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                toolClipingActionPerformed(evt);
            }
        });
        panelLeftToolBar.add(toolCliping);

        toolScaling.setIcon(new javax.swing.ImageIcon(MainWindow.class.getResource("/org/pgis/image/scale.png"))); // NOI18N
        toolScaling.setFocusable(false);
        toolScaling.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        toolScaling.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        toolScaling.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                toolScalingActionPerformed(evt);
            }
        });
        panelLeftToolBar.add(toolScaling);

        toolColor.setIcon(new javax.swing.ImageIcon(MainWindow.class.getResource("/org/pgis/image/color.png"))); // NOI18N
        toolColor.setFocusable(false);
        toolColor.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        toolColor.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        toolColor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                toolColorActionPerformed(evt);
            }
        });
        panelLeftToolBar.add(toolColor);

        getContentPane().add(panelLeftToolBar, java.awt.BorderLayout.WEST);

        panelStatusBar.setBackground(new java.awt.Color(255, 255, 255));
        panelStatusBar.setPreferredSize(new java.awt.Dimension(10, 30));
        //getContentPane().add(panelStatusBar, java.awt.BorderLayout.PAGE_END);

        panelToolBar.setLayout(new javax.swing.BoxLayout(panelToolBar, javax.swing.BoxLayout.LINE_AXIS));

        toolLeftArrow.setIcon(new javax.swing.ImageIcon(MainWindow.class.getResource("/org/pgis/image/left-arrow.png"))); // NOI18N
        toolLeftArrow.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                toolLeftArrowActionPerformed(evt);
            }
        });
        panelToolBar.add(toolLeftArrow);

        toolRightArrow.setIcon(new javax.swing.ImageIcon(MainWindow.class.getResource("/org/pgis/image/right-arrow.png"))); // NOI18N
        toolRightArrow.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                toolRightArrowActionPerformed(evt);
            }
        });
        panelToolBar.add(toolRightArrow);

        toolUpArrow.setIcon(new javax.swing.ImageIcon(MainWindow.class.getResource("/org/pgis/image/up-arrow.png"))); // NOI18N
        toolUpArrow.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                toolUpArrowActionPerformed(evt);
            }
        });
        panelToolBar.add(toolUpArrow);

        toolDownArrow.setIcon(new javax.swing.ImageIcon(MainWindow.class.getResource("/org/pgis/image/down-arrow.png"))); // NOI18N
        toolDownArrow.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                toolDownArrowActionPerformed(evt);
            }
        });
        panelToolBar.add(toolDownArrow);

        buttonClose.setIcon(new javax.swing.ImageIcon(MainWindow.class.getResource("/org/pgis/image/close.png"))); // NOI18N
        buttonClose.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonCloseActionPerformed(evt);
            }
        });
        panelToolBar.add(buttonClose);

        getContentPane().add(panelToolBar, java.awt.BorderLayout.PAGE_START);

        menuItemFile.setText("File");

        menuImportImage.setText("Import Image");
        menuImportImage.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuImportImageActionPerformed(evt);
            }
        });
        menuItemFile.add(menuImportImage);

        menuSave.setText("Save");
        menuItemFile.add(menuSave);

        menuSaveAs.setText("SaveAs");
        menuSaveAs.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuSaveAsActionPerformed(evt);
            }
        });
        menuItemFile.add(menuSaveAs);

        menuExit.setText("Exit");
        menuItemFile.add(menuExit);

        menuBar.add(menuItemFile);

        menuItemEdit.setText("Edit");

        menuObjectColor.setText("Object Color");
        menuItemEdit.add(menuObjectColor);

        menuBackColor.setText("Back Color");
        menuItemEdit.add(menuBackColor);

        menuUndo.setText("Undo");
        menuItemEdit.add(menuUndo);

        menuRedo.setText("Redo");
        menuItemEdit.add(menuRedo);

        menuDelete.setText("jMenuItem1");
        menuItemEdit.add(menuDelete);

        menuBar.add(menuItemEdit);

        menuItemOption.setText("Options");

        menuLight.setText("Light");
        menuItemOption.add(menuLight);

        menuCamera.setText("Camera");
        menuItemOption.add(menuCamera);

        menuTransform.setText("Transform");
        menuItemOption.add(menuTransform);

        menuScale.setText("Scale");
        menuItemOption.add(menuScale);

        menuBar.add(menuItemOption);

        menuItemImage.setText("Image");

        menuClip.setText("Clip");
        menuItemImage.add(menuClip);

        menuQuality.setText("Quality");
        menuItemImage.add(menuQuality);

        menuOpacity.setText("Opacity");
        menuItemImage.add(menuOpacity);

        menuBar.add(menuItemImage);

        menuItemView.setText("View");

        menuSolidView.setText("Solid");
        menuItemView.add(menuSolidView);

        menuWireframe.setText("Wireframe");
        menuItemView.add(menuWireframe);

        menuPoint.setText("Point");
        menuItemView.add(menuPoint);

        menuBar.add(menuItemView);

        setJMenuBar(menuBar);

        //setResizable(false);
        //setBounds((screenSize.width-832)/2, (screenSize.height-542)/2, 832, 542);
    }// </editor-fold>

    public void updateConnectingLines(Vector<ConnectingLine> v) {
    	connectingLineTable.setConnectingLines(v);

    	connectingLineTable.revalidate();
    	connectingLineTable.repaint();
    	panelToolLoad.removeAll();
    	panelToolLoad.add(connectingLineTable);
    	panelToolLoad.revalidate();
    	panelToolLoad.repaint();

    }

    private void setDefaultSpliterLocations(Dimension dimension) {
        int spliterWidth = (int)(dimension.getWidth()
        		- splitVertical.getMinimumSize().getWidth()
        		- panelLeftToolBar.getMinimumSize().getWidth());

        int spliterHeight = (int)(dimension.getHeight()
        		- scrollImageObjects.getMinimumSize().getWidth()
        		- panelToolBar.getMinimumSize().getHeight());
        splitVertical.setDividerLocation(spliterHeight);
        splitHorizontal.setDividerLocation(spliterWidth);
    }

    private void importImage() {
        try {
        	scene = new SurfaceScene();

        	panelContent.add(scene);
        	panelContent.repaint();

        } catch(Exception e) {
        	e.printStackTrace();
        }
    }

    private void menuImportImageActionPerformed(java.awt.event.ActionEvent evt) {
    	importImage();
    	scene.refresh();
    }

    private void menuSaveAsActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
    }

    private void toolClipingActionPerformed(java.awt.event.ActionEvent evt) {
    	setActionPanel(new ClippingPanel(scene));
    }

    private void toolImportActionPerformed(java.awt.event.ActionEvent evt) {
    	importImage();
    	scene.refresh();
    }

    private void toolViewActionPerformed(java.awt.event.ActionEvent evt) {
    	setActionPanel(new RepresentationPanel(scene));
    }

    private void toolTransformActionPerformed(java.awt.event.ActionEvent evt) {
    	setActionPanel(new DicomSettingsPanel(scene));
    }

    private void toolMeasureActionPerformed(java.awt.event.ActionEvent evt) {
    	setToolMeasurementPanel();
    }

    private void toolLightActionPerformed(java.awt.event.ActionEvent evt) {
    	setActionPanel(new LightPanel(scene));
    }

    private void toolInOutViewActionPerformed(java.awt.event.ActionEvent evt) {
    	setActionPanel(new QualityPanel(scene));
    }

    private void toolScalingActionPerformed(java.awt.event.ActionEvent evt) {
    	setActionPanel(new ScalePanel(scene));
    }

    private void toolColorActionPerformed(java.awt.event.ActionEvent evt) {
    	setActionPanel(new ColorPanel(scene));
    }

    private void toolLeftArrowActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
    }

    private void toolRightArrowActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
    }

    private void toolUpArrowActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
    }

    private void toolDownArrowActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
    }

    private void buttonCloseActionPerformed(java.awt.event.ActionEvent evt) {
        this.dispose();
    }

    private void toolAddFileActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
    }

    public void setToolMeasurementPanel() {
    	setActionPanel(new LineDistancePanel(scene));
    }

    private void setActionPanel(JPanel panel) {
    	panelImageObjects.removeAll();
    	panelImageObjects.setLayout(new BorderLayout());
    	panelImageObjects.add(panel);
    	panelImageObjects.revalidate();
    	panelImageObjects.repaint();
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(MainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(MainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(MainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(MainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new MainWindow().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify
    private javax.swing.JButton buttonClose;
    private javax.swing.JMenuItem menuBackColor;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JMenuItem menuCamera;
    private javax.swing.JMenuItem menuClip;
    private javax.swing.JMenuItem menuDelete;
    private javax.swing.JMenuItem menuExit;
    private javax.swing.JMenuItem menuImportImage;
    private javax.swing.JMenu menuItemEdit;
    private javax.swing.JMenu menuItemFile;
    private javax.swing.JMenu menuItemImage;
    private javax.swing.JMenu menuItemOption;
    private javax.swing.JMenu menuItemView;
    private javax.swing.JMenuItem menuLight;
    private javax.swing.JMenuItem menuObjectColor;
    private javax.swing.JMenuItem menuOpacity;
    private javax.swing.JMenuItem menuPoint;
    private javax.swing.JMenuItem menuQuality;
    private javax.swing.JMenuItem menuRedo;
    private javax.swing.JMenuItem menuSave;
    private javax.swing.JMenuItem menuSaveAs;
    private javax.swing.JMenuItem menuScale;
    private javax.swing.JMenuItem menuSolidView;
    private javax.swing.JMenuItem menuTransform;
    private javax.swing.JMenuItem menuUndo;
    private javax.swing.JMenuItem menuWireframe;
    private javax.swing.JPanel panelContent;
    private javax.swing.JPanel panelImageContent;
    private javax.swing.JPanel panelImageObjects;
    private javax.swing.JPanel panelLeftToolBar;
    private javax.swing.JPanel panelStatusBar;
    private javax.swing.JPanel panelToolBar;
    private javax.swing.JPanel panelToolLoad;
    private javax.swing.JScrollPane scrollImageObjects;
    private javax.swing.JScrollPane scrollTools;
    private javax.swing.JSplitPane splitHorizontal;
    private javax.swing.JSplitPane splitVertical;
    private javax.swing.JButton toolMeasure;
    private javax.swing.JButton toolAddFile;
    private javax.swing.JButton toolCliping;
    private javax.swing.JButton toolColor;
    private javax.swing.JButton toolDownArrow;
    private javax.swing.JButton toolImport;
    private javax.swing.JButton toolInOutView;
    private javax.swing.JButton toolLeftArrow;
    private javax.swing.JButton toolLight;
    private javax.swing.JButton toolRightArrow;
    private javax.swing.JButton toolScaling;
    private javax.swing.JButton toolTransform;
    private javax.swing.JButton toolUpArrow;
    private javax.swing.JButton toolView;
    // End of variables declaration
}
